package com.yd;

/**
 * Created by john on 16/3/9.
 */
public class GameRulesImpl implements GameRules {

    /**
     * 比牌
     * @param master 庄家
     * @param player 玩家
     * @return
     */
    public boolean compare(Player master, Player player) {
        if (master == null || player == null) {
            throw new IllegalArgumentException("被比较的对象不能为空");
        }
        boolean result;
        if (player.getStatus() == Player.STATUS_OVER) {
            // 玩家爆表, 赢
            result = true;
        } else if (master.getStatus() == Player.STATUS_OVER && player.getStatus() != Player.STATUS_OVER) {
            // 庄家爆表, 玩家没爆, 输
            result = false;
        } else if (master.getStatus() == Player.STATUS_FIVE && player.getStatus() == Player.STATUS_FIVE) {
            // 玩家五龙, 庄家五龙, 赢
            result = true;
        } else if (master.getStatus() != Player.STATUS_FIVE && player.getStatus() == Player.STATUS_FIVE) {
            // 玩家五龙, 庄家不是五龙, 输
            result = false;
        } else {
            // 其他情况比大小, 包括十点半
            result = master.getCount() >= player.getCount();
        }
        return result;
    }

}
